#ifndef FontEncoding_First
#define FontEncoding_First
#ifdef __GNUG__
#pragma interface
#endif

#include "RefCounted.h"
#include "Types.h"

#define _U_      01
#define _L_      02
#define _N_      04
#define _S_      010
#define _P_      020
#define _C_      040
#define _X_      0100
#define _B_      0200
#define _W_      0400
#define _A_      01000
#define _V_      02000

//---- CharInfo ----------------------------------------------------------------

class CharInfo {
public:
	u_short code;
	char hexval;
	char *name;
};

SimpleMetaDef(CharInfo);

//---- FontEncoding ------------------------------------------------------------

class FontEncoding : public RefCounted {
	char *name;
	int len;
	CharInfo *info;
	u_char *sortmap, *upcase, *lowercase;

public:
	MetaDef(FontEncoding);
	FontEncoding(const char *name, int l, CharInfo ci[], u_char *upcase,
							u_char *sortmap);
	~FontEncoding();
	const char *CodeToName(int code) const;
	int NameToCode(const char *name) const;
	const u_char *UpperCaseMap() const;
	const u_char *LowerCaseMap() const;
	const u_char *SortMap() const;
	bool CharClass(int code, int mask) const;
	int GetHexValue(int code) const;
};

inline bool FontEncoding::CharClass(int c, int mask) const
	{ return info[c].code & mask; }

inline int FontEncoding::GetHexValue(int c) const
	{ return info[c].hexval; }

extern const FontEncoding
	*gStdEncoding,
	*gMacEncoding,
	*gISOEncoding,
	*gSymbolEncoding;

#endif
